package com.thornbird.vehiclerecycling.config;

import com.thornbird.vehiclerecycling.service.ConfigService;
import com.thornbird.vehiclerecycling.util.PdfUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;

@Component
@Configuration
public class InitApplicationRunner implements ApplicationRunner {

    @Value("${app.font-path}")
    private String fontPath;

    private final ConfigService configService;

    @Autowired
    public InitApplicationRunner(ConfigService configService) {
        this.configService = configService;
    }

    @Override
    public void run(ApplicationArguments args) throws Exception {
        PdfUtil.setFontPath(fontPath);
        configService.findConfig();
    }

}
